const { ccclass, property } = cc._decorator;

@ccclass
export default class NumberBox extends cc.Component {

    @property(cc.Label)
    numText: cc.Label = null;

    num: number = 0;
    x: number = 0;
    y: number = 0;
    game = null;

    n_x = 0;
    n_y = 0;


    public set_text(num: number) {
        this.num = num
        this.numText.string = String(num)
        if (num > 25) {
            this.node.color = new cc.Color(45, 75, 142, 255)
            this.node.runAction(cc.sequence(cc.scaleTo(0.15, 1.5), cc.scaleTo(0.15, 1)));
        } else {
            this.node.color = new cc.Color(59, 91, 160, 255)
        }
    }

    onLoad() {
        this.n_x = this.node.x
        this.n_y = this.node.y

        this.node.on(cc.Node.EventType.TOUCH_START, event => {
            this.game.number_click(this.x, this.y)
        })
    }

    public setArrPosition(x, y) {
        this.x = x
        this.y = y
    }
}
